package servlets;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import shuyu.ArticleDao;
@WebServlet("/AddMessage")
public class AddMessage extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String title = req.getParameter("title");
		String context = req.getParameter("context");
		
		if (title != null && context != null) {
			ArticleDao articleDao = new ArticleDao();
			articleDao.addArticle(title, context);
		}
		
		resp.sendRedirect(req.getContextPath()+"/index.jsp");
	
	
	}
}
